package com.wx.sakura.service;
public class AccountingSyncClass implements Runnable{
    static int i=0;

    /**
     * 作用于静态方法,锁是当前class对象,也就是
     * AccountingSyncClass类对应的class对象
     */
    public static synchronized void increase(){
        i++;
    }

    /**
     * 非静态,访问时锁不一样不会发生互斥
     */
    public synchronized void increase4Obj(){
        i++;
    }

    @Override
    public void run() {
        for(int j=0;j<1000000;j++){
            increase();
        }
    }
    public static void main(String[] args) throws InterruptedException {
        AccountingSyncClass c = new AccountingSyncClass();
        //new新实例
        Thread t1=new Thread(new AccountingSyncClass());
        //new新实例
        Thread t2=new Thread(new AccountingSyncClass());
        //启动线程
        t1.start();t2.start();

        t1.join();t2.join();
        System.out.println(i);

        String s = "{\n" +
                "\t\"result\": [{\n" +
                "\t\t\"work _order _information\": {\n" +
                "\t\t\t\"importance_level\": \"高\",\n" +
                "\t\t\t\"analyse_result\": \"无\",\n" +
                "\t\t\t\"destination_port\": \"20000\",\n" +
                "\t\t\t\"sj_kind\": \"123\",\n" +
                "\t\t\t\"deal_terminal\": \"12\",\n" +
                "\t\t\t\"work_order_type\": \"test工单\",\n" +
                "\t\t\t\"solve_program\": \"无无\",\n" +
                "\t\t\t\"task_create_time\": \"2020-11-04 17:25:23\",\n" +
                "\t\t\t\"degree_confidentiality\": \"高\",\n" +
                "\t\t\t\"y_ip\": \"10.10.10.10\",\n" +
                "\t\t\t\"source_port\": \"10000\",\n" +
                "\t\t\t\"deadline_completion\": \"2020-11-10 15:40:41\",\n" +
                "\t\t\t\"smp_user_id\": \"003_liuzx\",\n" +
                "\t\t\t\"department\": \"测试组织\",\n" +
                "\t\t\t\"check_des\": \"无\",\n" +
                "\t\t\t\"process\": \"无\",\n" +
                "\t\t\t\"happen_time\": \"2020-11-04 15:42:24\",\n" +
                "\t\t\t\"close_time\": \"2020-11-04 17:35:29\",\n" +
                "\t\t\t\"check\": \"0\",\n" +
                "\t\t\t\"priority\": \"高\",\n" +
                "\t\t\t\"c_kind\": \"111\",\n" +
                "\t\t\t\"resik\": \"低\",\n" +
                "\t\t\t\"phone\": \"15900000000\",\n" +
                "\t\t\t\"security_number\": \"001\",\n" +
                "\t\t\t\"aid_ip\": \"20.20.20.20\",\n" +
                "\t\t\t\"effect\": \"无\",\n" +
                "\t\t\t\"jdr\": \"寇肖\",\n" +
                "\t\t\t\"describe\": \"lzxTest2\",\n" +
                "\t\t\t\"reply_arrange_time\": \"2020-11-10 15:40:41\"\n" +
                "\t\t}\n" +
                "\t}, {\n" +
                "\t\t\"history\": {\n" +
                "\t\t\t\"creator\": \"寇肖\",\n" +
                "\t\t\t\"task_create_time\": \"2020-11-04 17:25:23\",\n" +
                "\t\t\t\"audittime\": \"2020-11-04 17:25:24\",\n" +
                "\t\t\t\"orderid\": \"3343416\",\n" +
                "\t\t\t\"num\": \"1\",\n" +
                "\t\t\t\"auditresult\": \"\",\n" +
                "\t\t\t\"description\": \"Test2\",\n" +
                "\t\t\t\"state\": \"新建\",\n" +
                "\t\t\t\"auditname\": \"寇肖\"\n" +
                "\t\t}\n" +
                "\t}, {\n" +
                "\t\t\"history\": {\n" +
                "\t\t\t\"creator\": \"寇肖\",\n" +
                "\t\t\t\"task_create_time\": \"2020-11-04 17:25:23\",\n" +
                "\t\t\t\"audittime\": \"2020-11-04 17:51:23\",\n" +
                "\t\t\t\"orderid\": \"3343416\",\n" +
                "\t\t\t\"num\": \"2\",\n" +
                "\t\t\t\"auditresult\": \"同意\",\n" +
                "\t\t\t\"description\": \"Test2\",\n" +
                "\t\t\t\"state\": \"审批中\",\n" +
                "\t\t\t\"auditname\": \"寇肖\"\n" +
                "\t\t}\n" +
                "\t}, {\n" +
                "\t\t\"history\": {\n" +
                "\t\t\t\"creator\": \"寇肖\",\n" +
                "\t\t\t\"task_create_time\": \"2020-11-04 17:25:23\",\n" +
                "\t\t\t\"audittime\": \"\",\n" +
                "\t\t\t\"orderid\": \"3343416\",\n" +
                "\t\t\t\"num\": \"5\",\n" +
                "\t\t\t\"auditresult\": \"\",\n" +
                "\t\t\t\"description\": \"Test2\",\n" +
                "\t\t\t\"state\": \"处理中\",\n" +
                "\t\t\t\"auditname\": \"寇肖(处理中)\"\n" +
                "\t\t}\n" +
                "\t}, {\n" +
                "\t\t\"history\": {\n" +
                "\t\t\t\"creator\": \"寇肖\",\n" +
                "\t\t\t\"task_create_time\": \"2020-11-04 17:25:23\",\n" +
                "\t\t\t\"audittime\": \" \",\n" +
                "\t\t\t\"orderid\": \"3343416\",\n" +
                "\t\t\t\"num\": \"\",\n" +
                "\t\t\t\"auditresult\": \" \",\n" +
                "\t\t\t\"description\": \"Test2\",\n" +
                "\t\t\t\"state\": \"处理中\"\n" +
                "\t\t}\n" +
                "\t}],\n" +
                "\t\"respDesc\": \"查询成功\",\n" +
                "\t\"respCode\": \"00000\"\n" +
                "}";
    }
}

